package com.RMP
{
    import flash.display.*;
    import flash.events.*;
    import com.greensock.*;

    public class BackBtn extends Sprite
    {
        var fadeSpeed:Number;
        public var arrows:MovieClip;
        var myRoot:MovieClip;
        public var forward:MovieClip;
        public var back:MovieClip;

        public function BackBtn(param1:MovieClip, param2:Number) : void
        {
            myRoot = param1;
            fadeSpeed = param2;
            back.buttonMode = true;
            back.addEventListener(MouseEvent.MOUSE_OVER, overListener);
            back.addEventListener(MouseEvent.MOUSE_OUT, outListener);
            back.addEventListener(MouseEvent.CLICK, clickListener);
            forward.buttonMode = true;
            forward.addEventListener(MouseEvent.MOUSE_OVER, overListener);
            forward.addEventListener(MouseEvent.MOUSE_OUT, outListener);
            forward.addEventListener(MouseEvent.CLICK, clickListener);
            return;
        }

        function outListener(event:MouseEvent)
        {
            if (event.currentTarget == back)
            {
                TweenMax.to(arrows.back, fadeSpeed, {tint:myRoot.coldColor, overwrite:true});
            }
            else
            {
                TweenMax.to(arrows.forward, fadeSpeed, {tint:myRoot.coldColor, overwrite:true});
            }
            myRoot.closeBackToolTip();
            return;
        }

        function clickListener(event:MouseEvent)
        {
            if (event.currentTarget == back)
            {
                myRoot.browserBack();
            }
            else
            {
                myRoot.browserForward();
            }
            return;
        }

        function overListener(event:MouseEvent)
        {
            if (event.currentTarget == back)
            {
                TweenMax.to(arrows.back, fadeSpeed, {tint:myRoot.hotColor, overwrite:true});
                myRoot.changeToolTipText("Back");
            }
            else
            {
                TweenMax.to(arrows.forward, fadeSpeed, {tint:myRoot.hotColor, overwrite:true});
                myRoot.changeToolTipText("Forward");
            }
            myRoot.showBackToolTip();
            return;
        }

    }
}
